package io.renren.modules.region.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.modules.device.entity.vo.DeviceVO;
import io.renren.modules.region.dao.TCountryDao;
import io.renren.modules.region.entity.TCountryEntity;
import io.renren.modules.region.entity.vo.CountryVO;
import io.renren.modules.region.service.TCountryService;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * //Add the class description
 *
 * @author lhb
 * @date 2023/5/24
 */
@Service("tCountryService")
public class TCountryServiceImpl extends ServiceImpl<TCountryDao, TCountryEntity> implements TCountryService {
    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        List<CountryVO> countryList = new ArrayList<>();
        String key = (String) params.get("key");
        if (StringUtils.isEmpty(key)) {
            countryList = this.baseMapper.queryCountries();
        } else {
            key = "%".concat(key).concat("%");
            countryList = this.baseMapper.queryDevicesByKeySearch(key);
        }
        return new PageUtils(countryList, params);
    }
}
